#include"processBar.h"
#include<unistd.h>

typedef void (*callback_t)(int);

void downLoad(callback_t cb)
{
	int total =1000;
	int curr=0;
	while(curr<=total)
	{
		usleep(50000);
		int rate=curr*100/total;
		cb(rate);
		curr+=10;
	}
	printf("\n");
}

int main()
{
	printf("download 1: \n");
	downLoad(processbars);
	initbar();
	printf("download 2: \n");
	downLoad(processbars);
	initbar();
	printf("download 3: \n");
	downLoad(processbars);
	initbar();
	printf("download 4: \n");
	downLoad(processbars);
	initbar();
	printf("download 5: \n");
	downLoad(processbars);
	initbar();


	/*int total=1000;
	int curr=0;
	while(curr<=total)
	{
		processbars(curr*100/total);
		curr+=10;
		usleep(50000);
	}
	printf("\n");*/

	////倒计时
	//int cnt=10;
	//while(cnt>=0)
	//{
	//	printf("%-2d\r",cnt);
	//	fflush(stdout);
	//	cnt--;
	//	sleep(1);
	//}
	
	//printf("\n");

	//printf("hello world\n");
	//fflush(stdout);
	//sleep(2);	
	return 0;
}
